package org.brisling.oa.queryService;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.brisling.base.domain.ListDomain;
import org.brisling.common.ConstSysParam;
import org.brisling.oa.domain.OAProblemHandle;
import org.brisling.oa.domain.OASeniorTitleAppointment;
import org.brisling.oa.queryService.base.AbstractOAQueryService;
import org.brisling.sysman.queryService.QueryDictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * 
 * <p>Title: QueryOASeniorTitleAppointmentService</p>
 * <p>Description: 高级职称聘任模块查询服务类</p>
 * <p>Company: tongking</p>
 * @author jackson wang
 * @since 1.0
 * @version 1.0
 * @date 2016年7月9日 下午11:30:16
 */


//spring controller annotation
@RestController

//spring 业务模块映射地址，当前spring context 中必须确保唯一
@RequestMapping("/oaSeniorTitleAppointment/query")
public class QueryOASeniorTitleAppointmentService extends AbstractOAQueryService<OASeniorTitleAppointment> {
	
	
	
	//自动匹配数据字典服务类
	@Autowired
	private QueryDictionaryService dicService;	
	
	/**
	 * 构造函数
	 */
	public QueryOASeniorTitleAppointmentService(){
		//模块代码定义
		this.moduleName = ConstSysParam.MODULE_OA_SENIOR_TITLE_APPOINTMENT;
		
		//子系统定义
		this.subSystem = ConstSysParam.SUBSYSTEM_OA;
		
		//业务表（视图）名称定义
		this.tableName = ConstSysParam.VIEW_PREFIX +this.moduleName;
		
		//业务实体类定义
		this.clazz = OASeniorTitleAppointment.class;
		
		//查询过滤条件字段定义
		typeMap = this.getTypeMap(clazz);
		
		//排序字段定义
//		orderMap.put("bizno",null);
		
		
	}
	
	//spring entityManager 定义，unitName与配置文件中相应配置项必须匹配
	@PersistenceContext(unitName=ConstSysParam.SUBSYSTEM_SYSMAN)
	@Autowired
	protected void setEntityManager(EntityManager entityManager){
		this.entityManager = entityManager;		
	}
	
	//业务模块主页面（列表页面）映射地址定义，返回业务模块主页面（列表页面）spring 视图
	@RequestMapping("/mainPage.action")
	public ModelAndView getMainPage(){
		return this.getBizMainPage();
	}
	
	//业务模块编辑页面映射地址定义，返回业务模块编辑页面 spring 视图	
	@RequestMapping("/editPage.action")
	public ModelAndView getEditPage(){
		return this.getBizEditPage();
	}	
	
	//获取列表页面分页数据集方法
	@RequestMapping("/getListDomain.action")
	public ListDomain<OASeniorTitleAppointment> getListDomain(
			@RequestBody(required=false) String body){		
		
		return super.getListDomain(body);
	}
	
	//获取当前用户可操作（已签收，未签收）业务数据集方法
	@RequestMapping("/getOperateTaskListDomain.action")
	public ListDomain<OASeniorTitleAppointment> getUserCanoperateTask(@RequestBody(required=false) String body){
		return super.getUserCanoperateTask(body);
	}
	
	//获取当前用户已签收业务数据集
	@RequestMapping("/getSignedTaskListDomain.action")
	public ListDomain<OASeniorTitleAppointment> getUserSignedTask(@RequestBody(required=false) String body){
		return super.getUserSignedTask(body);
	}
	
	/**
	 * 获取当前用户未签收数据集
	 * @param body
	 * @return
	 */
	@RequestMapping("/getUnsignedTaskListDomain.action")
	public ListDomain<OASeniorTitleAppointment> getUserUnsignedTask(@RequestBody(required=false) String body){
		return super.getUserUnsignedTask(body);
	}
	
	/**
	 * 获取当前业务已完成数据集
	 * @param body
	 * @return
	 */
	@RequestMapping("/getFinishedTaskListDomain.action")
	public ListDomain<OASeniorTitleAppointment> getUserFinishedTask(@RequestBody(required=false) String body){
		return super.getUserFinishedTask(body);
	}
	
	/**
	 * 获取当前用户管理的数据集
	 * @param body
	 * @return
	 */
	
	@RequestMapping("/getUserManagedTaskDomain.action")
	public ListDomain<OASeniorTitleAppointment> getUserManagedTask(@RequestBody(required=false) String body){
		return super.getUserManagedTask(body);
	}
	@RequestMapping("/getAllTaskListDomain.action")
	public ListDomain<OASeniorTitleAppointment> getAllTask(@RequestBody(required=false) String body){
		return super.getAllTask(body);
	}
	/**
	 * 根据flow_state参数返回相应状态的当前业务数据集
	 * @param body
	 * @return
	 */
	
	@RequestMapping("/getTaskListDomain.action")
	public ListDomain<OASeniorTitleAppointment> getTaskListDomain(@RequestBody(required=false) String body){
		
		
		return super.getTaskListDomain(body);
		
	}
	
	
	/**
	 * 根据业务id查找单条业务记录
	 * @param id	业务id
	 * @return 业务记录 
	 */
	@RequestMapping("/getOne.action")
	public OASeniorTitleAppointment getOne(@RequestParam(value="id",required=false) Long id){
		return super.getOne(id);
	}
	
	/**
	 * 根据业务唯一编码查找单条业务记录
	 * @param identify	业务唯一编码
	 * @return 业务记录
	 */
	@RequestMapping("/getOneByIdentify.action")
	public OASeniorTitleAppointment getOneByIdentify(@RequestParam(value="identify",required=false) String identify){	
		return super.getOneByIdentify(identify);
	}
	
	/**
	 * 根据指定字段名及字段值查找记录
	 * @param field		字段名
	 * @param fieldVal	字段值
	 * @return
	 */
	@RequestMapping("/getOneByField.action")
	public OASeniorTitleAppointment getOneByField(@RequestParam(value="field",required=false) String field,
			@RequestParam(value="fieldVal",required=false) String fieldVal){	
		return super.getOneByIdentify(field,fieldVal);
	}
	
	/**
	 * 根据指定字段名及字段值查找记录
	 * @param field		字段名
	 * @param fieldVal	字段值
	 * @return
	 */
	@RequestMapping("/getOneByBizTable.action")
	public OASeniorTitleAppointment getOneByBizTable(@RequestParam(value="field",required=false) String field,
			@RequestParam(value="fieldVal",required=false) String fieldVal){	
		return super.getOneByTable(field,fieldVal);
	}
	/**
	 * 返回流程记录流程实例的执行记录
	 * @param body	包含procInstId在内的参数信息
	 * @return
	 */
	
	@RequestMapping("/flowHistoricsListDomain.action")
	public ListDomain<Object> getHistoricByProcInstId(@RequestBody(required=false) String body){
		
		String sql = dicService.getSqlByBizcode("flow_historics");				
		return super.getHistoricByProcInstId(body, sql);
	}
}
